//
//  Team9SeeOneViewController.m
//  Team9Project
//
//  Created by dlios on 15/10/19.
//  Copyright © 2015年 apple. All rights reserved.
//

#import "Team9SeeOneViewController.h"
#import <Masonry.h>

@interface Team9SeeOneViewController ()<UIScrollViewDelegate>
@property (nonatomic, strong) UIScrollView *scrolView;
@end

@implementation Team9SeeOneViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createScrollView];
    
    self.view.backgroundColor = [UIColor blackColor];

    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 550 / 667.0 * HEGHT, WIDTH, 30 / 667.0 * HEGHT
                                                                    )];
    [self.view addSubview:titleLabel];
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = @"下滑图片返回";
    
    
    
    
    
    
    
    
}


- (void)setPicArray:(NSArray *)picArray{
    if (_picArray != picArray) {
        _picArray = picArray;
    }
    
    
    
}



- (void)createScrollView{
    
  
    self.scrolView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 150, WIDTH, HEGHT  - 300)];
    self.scrolView.backgroundColor = [UIColor redColor];
    [self.view addSubview:self.scrolView];
    self.scrolView.delegate = self;
    self.scrolView.contentSize = CGSizeMake(WIDTH * self.picArray.count, 0);
    self.scrolView.contentOffset = CGPointMake(WIDTH * self.number, 0);
    self.scrolView.showsHorizontalScrollIndicator = NO;
    self.scrolView.showsVerticalScrollIndicator = NO;
    self.scrolView.bounces = NO;
    self.scrolView.pagingEnabled = YES;
   
    for (NSInteger number = 0; number < self.picArray.count; number++) {
        UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH * number, 0, WIDTH , HEGHT  - 300)];
        imageview.backgroundColor = [UIColor grayColor];
        [Team9Tool sd_imageView:imageview image:self.picArray[number] placeholder:[UIImage imageNamed:@"111"]];
        [self.scrolView addSubview:imageview];

        
        // 添加轻扫方法
        imageview.userInteractionEnabled = YES;
        UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeAction:)];
        [imageview addGestureRecognizer:swipe];
        
        //向下
        swipe.direction = UISwipeGestureRecognizerDirectionDown;

        
    }
    
   


}

#pragma mark 下滑返回上一页
- (void)swipeAction:(UISwipeGestureRecognizer *)swipe{

    if (swipe.direction ==  UISwipeGestureRecognizerDirectionDown) {
       [self dismissViewControllerAnimated:YES completion:^{
           
           
       }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
